package smallestRangeI;

public class Solution {
    public int smallestRangeI(int[] nums, int k) {
        int max = Integer.MIN_VALUE;
        int min = Integer.MIN_VALUE;
        for (int i = 0; i < nums.length; i++) {
            max = Math.max(nums[i],max);
            min = Math.min(nums[i],min);
        }
        return Math.max(0,max-k-(min+k));
    }
}
